Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tablet tilt values returning bad values #56438

Merged
merged 1 commit into from
Jan 3, 2022

Conversation

madmiraal
Copy link
Contributor

Currently, InputEventMouseMotion's tilt property is wrong. With a pen that does support tilt, the tilt.y value is always 0. Furthermore, when the pen doesn't support tilt, the tilt.x value is always 0.007874 instead of 0.

This PR ensures that when a devices supports tilt that the correct tilt values in the range -1 to 1 are returned, and when a device doesn't support tilt or the tilt values returned are 0 that a Vector(0, 0) is returned.

Fixes #56428

Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have any tablet with tilt support to test it, but changes seems fine.

Note: I assume VALUATOR_TILT* range is -x .. x and pen_tilt_*_range[0] is always negative, have not found any documentation to check it.

@akien-mga akien-mga merged commit 1d6f8ad into godotengine:master Jan 3, 2022
@akien-mga
Copy link
Member

Thanks!

@madmiraal
Copy link
Contributor Author

Note: I assume VALUATOR_TILT* range is -x .. x and pen_tilt_*_range[0] is always negative, have not found any documentation to check it.

Although there is no reason a driver couldn't specify a minimum greater than zero, I think it's a reasonable assumption to expect the minimum value to be <= 0. The real problem is the minimum and maximum values are not necessarily symmetrical. On my Wacom tablet, the values are -64 and 63. However, if for some obscure reason, a driver specifies a minimum greater than zero, I think it would still be correct to keep the shifted value and just scale it to be between 0 and 1 as done in this PR.

@madmiraal madmiraal deleted the fix-56428 branch January 4, 2022 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InputEventMouseMotion tilt.y is always zero
4 participants